-- Relationship Creation

-- Table tblTechnology Fields
IF ( NOT EXISTS( SELECT syso.id FROM sysconstraints sysc INNER JOIN sysobjects syso ON syso.id = sysc.id INNER JOIN sysobjects syso2 ON syso2.id = sysc.constid WHERE ( syso.name = 'tblTechnology' ) AND ( syso2.name = 'FK_Technology_ExpertiseLevel' ) ) )
   ALTER TABLE dbo.[tblTechnology] ADD CONSTRAINT [FK_Technology_ExpertiseLevel] FOREIGN KEY ( [ExpertiseLevelId] ) REFERENCES dbo.[tblExpertiseLevel] ( [Id] ) 
GO


-- Table tblGoal Fields
IF ( NOT EXISTS( SELECT syso.id FROM sysconstraints sysc INNER JOIN sysobjects syso ON syso.id = sysc.id INNER JOIN sysobjects syso2 ON syso2.id = sysc.constid WHERE ( syso.name = 'tblGoal' ) AND ( syso2.name = 'FK_Goal_Status' ) ) )
   ALTER TABLE dbo.[tblGoal] ADD CONSTRAINT [FK_Goal_Status] FOREIGN KEY ( [StatusId] ) REFERENCES dbo.[tblGoalStatus] ( [Id] ) 
GO


-- Table tblGoalRequiredExpertise Fields
IF ( NOT EXISTS( SELECT syso.id FROM sysconstraints sysc INNER JOIN sysobjects syso ON syso.id = sysc.id INNER JOIN sysobjects syso2 ON syso2.id = sysc.constid WHERE ( syso.name = 'tblGoalRequiredExpertise' ) AND ( syso2.name = 'FK_GoalRequiredExpertise_Goal' ) ) )
   ALTER TABLE dbo.[tblGoalRequiredExpertise] ADD CONSTRAINT [FK_GoalRequiredExpertise_Goal] FOREIGN KEY ( [GoalId] ) REFERENCES dbo.[tblGoal] ( [Id] ) 
GO

IF ( NOT EXISTS( SELECT syso.id FROM sysconstraints sysc INNER JOIN sysobjects syso ON syso.id = sysc.id INNER JOIN sysobjects syso2 ON syso2.id = sysc.constid WHERE ( syso.name = 'tblGoalRequiredExpertise' ) AND ( syso2.name = 'FK_GoalRequiredExpertise_Technology' ) ) )
   ALTER TABLE dbo.[tblGoalRequiredExpertise] ADD CONSTRAINT [FK_GoalRequiredExpertise_Technology] FOREIGN KEY ( [TechnologyId] ) REFERENCES dbo.[tblTechnology] ( [Id] ) 
GO

